﻿using brand.cyt369.com.models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using brand.cyt369.com.MODELS;

namespace brand.cyt369.com.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            //轮播部分
            var brandTop10 = brand.cyt369.com.dal.BrandService.Instance.BrandTop10Gets();
            var carousels = brand.cyt369.com.dal.CarouselService.Instance.CarouselsGets();//轮播
            var categorys=brand.cyt369.com.dal.CategoryService.Instance.ParentCategorysGets();//轮播左侧的类别
            ViewBag.brandTop10 = brandTop10;
            ViewBag.carousels= carousels;
            ViewBag.categorys= categorys;

            //热门加盟
            var hotBrandTop36 = brand.cyt369.com.dal.HotBrandService.Instance.HotBrandTop36Gets();
            ViewBag.hotBrandTop36 = hotBrandTop36;

            //热门类别 的品牌
            Dictionary<int, IQueryable<brand.cyt369.com.models.Brand>> dict = new Dictionary<int, IQueryable<brand.cyt369.com.models.Brand>>();
            foreach (var category in categorys)
            {
                var brands = brand.cyt369.com.dal.BrandService.Instance.GetBrandsByCategoryParentID(category.Id);
                dict[category.Id] = brands;
            }
            ViewBag.dict = dict;
            return View("Index");
        }

    }
}
